package com.ateam.biz.impl;

import java.util.List;

import com.ateam.biz.GroupsBiz;
import com.ateam.dao.GroupsDao;
import com.ateam.pojo.Groups;

/** 
* @author WuYuan
* 
*/
public class GroupsBizImpl implements GroupsBiz {
	private GroupsDao groupsDao;
	
	public GroupsDao getGroupsDao() {
		return groupsDao;
	}

	public void setGroupsDao(GroupsDao groupsDao) {
		this.groupsDao = groupsDao;
	}

	@Override
	public int addGroup(Groups group, int userid) {
		try {
			groupsDao.addGroup(group);
			return groupsDao.addGroupLeader(userid, group.getGroupid());
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return 0;
	}

	@Override
	public List<Groups> getGroupsByUser(int userid) {
		try {
			return groupsDao.getGroupsByUser(userid);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

	@Override
	public Groups getGroupDetail(int groupid) {
		try {
			return groupsDao.getGroupByGroupid(groupid);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}

}
